//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS SageMakerRuntime service.
///
///  The Amazon SageMaker AI runtime API.
public struct SageMakerRuntime: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the SageMakerRuntime client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "SageMakerRuntime",
            serviceIdentifier: "runtime.sagemaker",
            signingName: "sagemaker",
            serviceProtocol: .restjson,
            apiVersion: "2017-05-13",
            endpoint: endpoint,
            variantEndpoints: Self.variantEndpoints,
            errorType: SageMakerRuntimeErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }




    /// FIPS and dualstack endpoints
    static var variantEndpoints: [EndpointVariantType: AWSServiceConfig.EndpointVariant] {[
        [.fips]: .init(endpoints: [
            "af-south-1": "runtime-fips.sagemaker.af-south-1.amazonaws.com",
            "ap-east-1": "runtime-fips.sagemaker.ap-east-1.amazonaws.com",
            "ap-east-2": "runtime-fips.sagemaker.ap-east-2.amazonaws.com",
            "ap-northeast-1": "runtime-fips.sagemaker.ap-northeast-1.amazonaws.com",
            "ap-northeast-2": "runtime-fips.sagemaker.ap-northeast-2.amazonaws.com",
            "ap-northeast-3": "runtime-fips.sagemaker.ap-northeast-3.amazonaws.com",
            "ap-south-1": "runtime-fips.sagemaker.ap-south-1.amazonaws.com",
            "ap-south-2": "runtime-fips.sagemaker.ap-south-2.amazonaws.com",
            "ap-southeast-1": "runtime-fips.sagemaker.ap-southeast-1.amazonaws.com",
            "ap-southeast-2": "runtime-fips.sagemaker.ap-southeast-2.amazonaws.com",
            "ap-southeast-3": "runtime-fips.sagemaker.ap-southeast-3.amazonaws.com",
            "ap-southeast-4": "runtime-fips.sagemaker.ap-southeast-4.amazonaws.com",
            "ap-southeast-5": "runtime-fips.sagemaker.ap-southeast-5.amazonaws.com",
            "ap-southeast-7": "runtime-fips.sagemaker.ap-southeast-7.amazonaws.com",
            "ca-central-1": "runtime-fips.sagemaker.ca-central-1.amazonaws.com",
            "ca-west-1": "runtime-fips.sagemaker.ca-west-1.amazonaws.com",
            "eu-central-1": "runtime-fips.sagemaker.eu-central-1.amazonaws.com",
            "eu-central-2": "runtime-fips.sagemaker.eu-central-2.amazonaws.com",
            "eu-north-1": "runtime-fips.sagemaker.eu-north-1.amazonaws.com",
            "eu-south-1": "runtime-fips.sagemaker.eu-south-1.amazonaws.com",
            "eu-south-2": "runtime-fips.sagemaker.eu-south-2.amazonaws.com",
            "eu-west-1": "runtime-fips.sagemaker.eu-west-1.amazonaws.com",
            "eu-west-2": "runtime-fips.sagemaker.eu-west-2.amazonaws.com",
            "eu-west-3": "runtime-fips.sagemaker.eu-west-3.amazonaws.com",
            "il-central-1": "runtime-fips.sagemaker.il-central-1.amazonaws.com",
            "me-central-1": "runtime-fips.sagemaker.me-central-1.amazonaws.com",
            "me-south-1": "runtime-fips.sagemaker.me-south-1.amazonaws.com",
            "mx-central-1": "runtime-fips.sagemaker.mx-central-1.amazonaws.com",
            "sa-east-1": "runtime-fips.sagemaker.sa-east-1.amazonaws.com",
            "us-east-1": "runtime-fips.sagemaker.us-east-1.amazonaws.com",
            "us-east-2": "runtime-fips.sagemaker.us-east-2.amazonaws.com",
            "us-gov-east-1": "runtime.sagemaker.us-gov-east-1.amazonaws.com",
            "us-gov-west-1": "runtime.sagemaker.us-gov-west-1.amazonaws.com",
            "us-west-1": "runtime-fips.sagemaker.us-west-1.amazonaws.com",
            "us-west-2": "runtime-fips.sagemaker.us-west-2.amazonaws.com"
        ])
    ]}

    // MARK: API Calls

    /// After you deploy a model into production using Amazon SageMaker AI hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint.  For an overview of Amazon SageMaker AI, see How It Works.  Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.  Calls to InvokeEndpoint are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference. A customer's model containers must respond to requests within 60 seconds. The model itself can have a maximum processing time of 60 seconds before responding to invocations. If your model is going to take 50-60 seconds of processing time, the SDK socket timeout should be set to be 70 seconds.  Endpoints are scoped to an individual account, and are not public. The URL does not contain the account ID, but Amazon SageMaker AI determines the account ID from the authentication token that is supplied by the caller.
    @Sendable
    @inlinable
    public func invokeEndpoint(_ input: InvokeEndpointInput, logger: Logger = AWSClient.loggingDisabled) async throws -> InvokeEndpointOutput {
        try await self.client.execute(
            operation: "InvokeEndpoint", 
            path: "/endpoints/{EndpointName}/invocations", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// After you deploy a model into production using Amazon SageMaker AI hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint.  For an overview of Amazon SageMaker AI, see How It Works.  Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.  Calls to InvokeEndpoint are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference. A customer's model containers must respond to requests within 60 seconds. The model itself can have a maximum processing time of 60 seconds before responding to invocations. If your model is going to take 50-60 seconds of processing time, the SDK socket timeout should be set to be 70 seconds.  Endpoints are scoped to an individual account, and are not public. The URL does not contain the account ID, but Amazon SageMaker AI determines the account ID from the authentication token that is supplied by the caller.
    ///
    /// Parameters:
    ///   - accept: The desired MIME type of the inference response from the model container.
    ///   - body: Provides input data, in the format specified in the ContentType request header. Amazon SageMaker AI passes all of the data in the body to the model.  For information about the format of the request body, see Common Data Formats-Inference.
    ///   - contentType: The MIME type of the input data in the request body.
    ///   - customAttributes: Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).  The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.  This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
    ///   - enableExplanations: An optional JMESPath expression used to override the EnableExplanations parameter of the ClarifyExplainerConfig API. See the EnableExplanations section in the developer guide for more information.
    ///   - endpointName: The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.
    ///   - inferenceComponentName: If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke.
    ///   - inferenceId: If you provide a value, it is added to the captured data when you enable data capture on the endpoint. For information about data capture, see Capture Data.
    ///   - sessionId: Creates a stateful session or identifies an existing one. You can do one of the following:   Create a stateful session by specifying the value NEW_SESSION.   Send your request to an existing stateful session by specifying the ID of that session.   With a stateful session, you can send multiple requests to a stateful model. When you create a session with a stateful model, the model must create the session ID and set the expiration time. The model must also provide that information in the response to your request. You can get the ID and timestamp from the NewSessionId response parameter. For any subsequent request where you specify that session ID, SageMaker AI routes the request to the same instance that supports the session.
    ///   - targetContainerHostname: If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.
    ///   - targetModel: The model to request for inference when invoking a multi-model endpoint.
    ///   - targetVariant: Specify the production variant to send the inference request to when invoking an endpoint that is running two or more variants. Note that this parameter overrides the default behavior for the endpoint, which is to distribute the invocation traffic based on the variant weights. For information about how to use variant targeting to perform a/b testing, see Test models in production
    ///   - logger: Logger use during operation
    @inlinable
    public func invokeEndpoint(
        accept: String? = nil,
        body: AWSHTTPBody? = nil,
        contentType: String? = nil,
        customAttributes: String? = nil,
        enableExplanations: String? = nil,
        endpointName: String,
        inferenceComponentName: String? = nil,
        inferenceId: String? = nil,
        sessionId: String? = nil,
        targetContainerHostname: String? = nil,
        targetModel: String? = nil,
        targetVariant: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> InvokeEndpointOutput {
        let input = InvokeEndpointInput(
            accept: accept, 
            body: body, 
            contentType: contentType, 
            customAttributes: customAttributes, 
            enableExplanations: enableExplanations, 
            endpointName: endpointName, 
            inferenceComponentName: inferenceComponentName, 
            inferenceId: inferenceId, 
            sessionId: sessionId, 
            targetContainerHostname: targetContainerHostname, 
            targetModel: targetModel, 
            targetVariant: targetVariant
        )
        return try await self.invokeEndpoint(input, logger: logger)
    }

    /// After you deploy a model into production using Amazon SageMaker AI hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint in an asynchronous manner. Inference requests sent to this API are enqueued for asynchronous processing. The processing of the inference request may or may not complete before you receive a response from this API. The response from this API will not contain the result of the inference request but contain information about where you can locate it. Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.  Calls to InvokeEndpointAsync are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.
    @Sendable
    @inlinable
    public func invokeEndpointAsync(_ input: InvokeEndpointAsyncInput, logger: Logger = AWSClient.loggingDisabled) async throws -> InvokeEndpointAsyncOutput {
        try await self.client.execute(
            operation: "InvokeEndpointAsync", 
            path: "/endpoints/{EndpointName}/async-invocations", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// After you deploy a model into production using Amazon SageMaker AI hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint in an asynchronous manner. Inference requests sent to this API are enqueued for asynchronous processing. The processing of the inference request may or may not complete before you receive a response from this API. The response from this API will not contain the result of the inference request but contain information about where you can locate it. Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.  Calls to InvokeEndpointAsync are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.
    ///
    /// Parameters:
    ///   - accept: The desired MIME type of the inference response from the model container.
    ///   - contentType: The MIME type of the input data in the request body.
    ///   - customAttributes: Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).  The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.  This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
    ///   - endpointName: The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.
    ///   - inferenceId: The identifier for the inference request. Amazon SageMaker AI will generate an identifier for you if none is specified.
    ///   - inputLocation: The Amazon S3 URI where the inference request payload is stored.
    ///   - invocationTimeoutSeconds: Maximum amount of time in seconds a request can be processed before it is marked as expired. The default is 15 minutes, or 900 seconds.
    ///   - requestTTLSeconds: Maximum age in seconds a request can be in the queue before it is marked as expired. The default is 6 hours, or 21,600 seconds.
    ///   - logger: Logger use during operation
    @inlinable
    public func invokeEndpointAsync(
        accept: String? = nil,
        contentType: String? = nil,
        customAttributes: String? = nil,
        endpointName: String,
        inferenceId: String? = nil,
        inputLocation: String? = nil,
        invocationTimeoutSeconds: Int? = nil,
        requestTTLSeconds: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> InvokeEndpointAsyncOutput {
        let input = InvokeEndpointAsyncInput(
            accept: accept, 
            contentType: contentType, 
            customAttributes: customAttributes, 
            endpointName: endpointName, 
            inferenceId: inferenceId, 
            inputLocation: inputLocation, 
            invocationTimeoutSeconds: invocationTimeoutSeconds, 
            requestTTLSeconds: requestTTLSeconds
        )
        return try await self.invokeEndpointAsync(input, logger: logger)
    }

    /// Invokes a model at the specified endpoint to return the inference response as a stream. The inference stream provides the response payload incrementally as a series of parts. Before you can get an inference stream, you must have access to a model that's deployed using Amazon SageMaker AI hosting services, and the container for that model must support inference streaming. For more information that can help you use this API, see the following sections in the Amazon SageMaker AI Developer Guide:   For information about how to add streaming support to a model, see How Containers Serve Requests.   For information about how to process the streaming response, see Invoke real-time endpoints.   Before you can use this operation, your IAM permissions must allow the sagemaker:InvokeEndpoint action. For more information about Amazon SageMaker AI actions for IAM policies, see Actions, resources, and condition keys for Amazon SageMaker AI in the IAM Service Authorization Reference. Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.  Calls to InvokeEndpointWithResponseStream are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.
    @Sendable
    @inlinable
    public func invokeEndpointWithResponseStream(_ input: InvokeEndpointWithResponseStreamInput, logger: Logger = AWSClient.loggingDisabled) async throws -> InvokeEndpointWithResponseStreamOutput {
        try await self.client.execute(
            operation: "InvokeEndpointWithResponseStream", 
            path: "/endpoints/{EndpointName}/invocations-response-stream", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Invokes a model at the specified endpoint to return the inference response as a stream. The inference stream provides the response payload incrementally as a series of parts. Before you can get an inference stream, you must have access to a model that's deployed using Amazon SageMaker AI hosting services, and the container for that model must support inference streaming. For more information that can help you use this API, see the following sections in the Amazon SageMaker AI Developer Guide:   For information about how to add streaming support to a model, see How Containers Serve Requests.   For information about how to process the streaming response, see Invoke real-time endpoints.   Before you can use this operation, your IAM permissions must allow the sagemaker:InvokeEndpoint action. For more information about Amazon SageMaker AI actions for IAM policies, see Actions, resources, and condition keys for Amazon SageMaker AI in the IAM Service Authorization Reference. Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.  Calls to InvokeEndpointWithResponseStream are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.
    ///
    /// Parameters:
    ///   - accept: The desired MIME type of the inference response from the model container.
    ///   - body: Provides input data, in the format specified in the ContentType request header. Amazon SageMaker AI passes all of the data in the body to the model.  For information about the format of the request body, see Common Data Formats-Inference.
    ///   - contentType: The MIME type of the input data in the request body.
    ///   - customAttributes: Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).  The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.  This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
    ///   - endpointName: The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.
    ///   - inferenceComponentName: If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke for a streaming response.
    ///   - inferenceId: An identifier that you assign to your request.
    ///   - sessionId: The ID of a stateful session to handle your request. You can't create a stateful session by using the InvokeEndpointWithResponseStream action. Instead, you can create one by using the  InvokeEndpoint action. In your request, you specify NEW_SESSION for the SessionId request parameter. The response to that request provides the session ID for the NewSessionId response parameter.
    ///   - targetContainerHostname: If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.
    ///   - targetVariant: Specify the production variant to send the inference request to when invoking an endpoint that is running two or more variants. Note that this parameter overrides the default behavior for the endpoint, which is to distribute the invocation traffic based on the variant weights. For information about how to use variant targeting to perform a/b testing, see Test models in production
    ///   - logger: Logger use during operation
    @inlinable
    public func invokeEndpointWithResponseStream(
        accept: String? = nil,
        body: AWSHTTPBody? = nil,
        contentType: String? = nil,
        customAttributes: String? = nil,
        endpointName: String,
        inferenceComponentName: String? = nil,
        inferenceId: String? = nil,
        sessionId: String? = nil,
        targetContainerHostname: String? = nil,
        targetVariant: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> InvokeEndpointWithResponseStreamOutput {
        let input = InvokeEndpointWithResponseStreamInput(
            accept: accept, 
            body: body, 
            contentType: contentType, 
            customAttributes: customAttributes, 
            endpointName: endpointName, 
            inferenceComponentName: inferenceComponentName, 
            inferenceId: inferenceId, 
            sessionId: sessionId, 
            targetContainerHostname: targetContainerHostname, 
            targetVariant: targetVariant
        )
        return try await self.invokeEndpointWithResponseStream(input, logger: logger)
    }
}

extension SageMakerRuntime {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: SageMakerRuntime, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
